package cn.com.cifi.mars.mapper.wrapper;

import cn.com.cifi.mars.entity.ReturnPlanVersion;
import cn.com.cifi.mars.entity.SignPlanVersion;
import cn.com.cifi.mars.mapper.mars.SignPlanVersionMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author: JingYuanXiang
 * @date: 2020/11/8 15:30
 */
@Component
public class SignPlanVersionWrapper {

    @Autowired
    private SignPlanVersionMapper signPlanVersionMapper;

    /**
     * 查询最新签约计划版本
     * @param stageId 分期id
     * @param versionType 版本类型
     * @param versionState 版本状态
     * @param isDelete 是否删除
     * @return
     */
    public SignPlanVersion selectLatestByStageIdAndVersionTypeAndVersionState(String stageId, String versionType, String versionState, int isDelete){
        QueryWrapper<SignPlanVersion> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("projectf_id",stageId)
                .eq("version_type", versionType)
                .eq("version_state", versionState)
                .eq("is_delete", isDelete)
                .orderByDesc("create_time")
                .last("limit 1");
        return signPlanVersionMapper.selectOne(queryWrapper);
    }
}
